using System;
using System.Collections.Generic;
using System.Data;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
using Orchard.Indexing;

namespace BB.SoundCloudWebPlayer.DataMigrations
{
    public class Migrations : DataMigrationImpl {

        public int Create() {
            SchemaBuilder.CreateTable("SoundCloudTrackPartRecord", table => table
				.ContentPartRecord()
				.Column("TrackName", DbType.String)
				.Column("TrackLocation", DbType.String)
			);


            return 1;
        }

        public int UpdateFrom1()
        {
            ContentDefinitionManager.AlterPartDefinition("SoundCloudTrackPart",
              builder => builder.Attachable());
            return 2;
        }
        
        public int UpdateFrom2()
        {
            ContentDefinitionManager.AlterTypeDefinition("SoundCloudTrack", cfg => cfg
                .WithPart("CommonPart")
                .WithPart("RoutePart")
                .WithPart("SoundCloudTrackPart")
                .WithPart("BodyPart")
                .WithPart("CommentsPart")
                .WithPart("TagsPart")
                .WithPart("LocalizationPart")
              .Creatable()
              .Indexed());
            return 3;
        }
        

    }
}